<%@ page import="main_com.pojo.LookDateBean" %>
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人信息管理系统 - 查看日程</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        /* 通用样式 */
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f4f7fc;
            margin: 0;
            padding: 0;
            color: #333;
        }

        a {
            text-decoration: none; /* 去掉下划线 */
        }

        .container {
            width: 80%;
            margin: 50px auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        h1 {
            text-align: center;
            color: #4CAF50;
            font-size: 2em;
            margin-bottom: 30px;
        }

        /* 导航栏 */
        .nav-links {
            text-align: center;
            margin-bottom: 20px;
        }

        .nav-links a {
            margin: 0 15px;
            color: #4CAF50;
            text-decoration: none;
            font-size: 1.2em;
            padding: 8px 15px;
            border-radius: 5px;
            background-color: #f4f7fc;
            transition: background-color 0.3s;
        }

        .nav-links a:hover {
            background-color: #4CAF50;
            color: #fff;
        }

        /* 表格样式 */
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 30px;
        }

        table th, table td {
            padding: 12px;
            text-align: center;
            border: 1px solid #ddd;
        }

        table th {
            background-color: #4CAF50;
            color: #fff;
        }

        table tr:nth-child(even) {
            background-color: #f2f2f2;
        }

        .no-schedule {
            text-align: center;
            font-size: 1.2em;
            color: #f44336;
        }

        /* 分页样式 */
        .pagination {
            text-align: center;
            margin-top: 30px;
        }

        .pagination a {
            padding: 10px 20px;
            margin: 0 5px;
            color: #4CAF50;
            text-decoration: none;
            border: 1px solid #4CAF50;
            border-radius: 5px;
            transition: background-color 0.3s, color 0.3s;
        }

        .pagination a:hover {
            background-color: #4CAF50;
            color: #fff;
        }

        .pagination .active {
            background-color: #4CAF50;
            color: #fff;
        }

        /* 底部样式 */
        .footer {
            text-align: center;
            margin-top: 40px;
            font-size: 0.9em;
            color: #777;
        }

        .footer a {
            color: #4CAF50;
            text-decoration: none;
        }

        .footer a:hover {
            text-decoration: underline;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .container {
                width: 90%;
                padding: 15px;
            }

            .nav-links a {
                margin: 5px;
                font-size: 1em;
            }

            table th, table td {
                font-size: 0.9em;
                padding: 8px;
            }

            .pagination a {
                font-size: 0.9em;
                padding: 8px 16px;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <h1>查看日程</h1>

    <!-- 导航链接 -->
    <div class="nav-links">
        <a href="javascript:void(0);" style="background-color: #4CAF50;color: #fff;">查看日程</a>
        <a href="http://localhost/dateManager/addDate.jsp">增加日程</a>
        <a href="http://localhost/dateManager/updateDate.jsp">修改日程</a>
        <a href="http://localhost/dateManager/deleteDate.jsp">删除日程</a>
    </div>

    <!-- 日程表格 -->
    <table>
        <thead>
        <tr>
            <th>日程时间</th>
            <th>日程内容</th>
        </tr>
        </thead>
        <tbody>
        <%
            ArrayList<LookDateBean> datelist = (ArrayList<LookDateBean>) session.getAttribute("datelist");
            if (datelist == null || datelist.isEmpty()) {
        %>
        <tr>
            <td colspan="2" class="no-schedule">您还没有任何日程安排！</td>
        </tr>
        <%
        } else {
            for (LookDateBean dd : datelist) {
        %>
        <tr>
            <td><%= dd.getDate() %>
            </td>
            <td><%= dd.getThing() %>
            </td>
        </tr>
        <%
                }
            }
        %>
        </tbody>
    </table>

    <!-- 分页导航 -->
    <div class="pagination">
        <%
            int currentPage = (Integer) session.getAttribute("currentPage");
            int totalPages = (Integer) session.getAttribute("totalPages");

            // 上一页
            if (currentPage > 1) {
        %>
        <a href="http://localhost/LookDateController/lookDate?page=<%= currentPage - 1 %>">&laquo; 上一页</a>
        <%
            }

            // 页码
            for (int i = 1; i <= totalPages; i++) {
        %>
        <a href="http://localhost/LookDateController/lookDate?page=<%= i %>"
           class="<%= (i == currentPage)? "active" : "" %>"><%= i %>
        </a>
        <%
            }

            // 下一页
            if (currentPage < totalPages) {
        %>
        <a href="http://localhost/LookDateController/lookDate?page=<%= currentPage + 1 %>">下一页 &raquo;</a>
        <%
            }
        %>
    </div>

</div>
<div class="footer">
    <p>© 2024 个人信息管理系统 | <a href="http://localhost/">返回首页</a></p>
</div>
</body>
</html>
